package com.qf.yuandanwork.entity;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class User {
    private Integer id;
    private String name;
    private String password;
    private String sex;
    private Date birthday;
    private Date registTime;
    private String auth;

    // 添加字段status，用于记录该用户是否被点过名，初始值0代表没被点过
    private String status;

    // 添加账户余额字段
    private Integer amount;

    //转换格式
    public String toCSVString(){
        return this.getId()+","+this.getName()+","+this.getPassword()+","+this.getSex()+","+this.getBirthday()+","+
               this.getRegistTime()+","+this.getAuth()+this.getStatus()+","+this.getAmount();
    }
    public static List<String> listToString(List<User> users){
        List<String> list=new ArrayList<>();
        for (User user : users) {
            String s = user.toCSVString();
            list.add(s);
        }

        return list;
    }
}
